/* File:        	PEPLog.java
* Package:			com.tecnalia.authz.log
* Created:      	29-abr-2011
* Last Changed: 	0:11:10
* Author:       	Borja Urkizu borja.urquizu@tecnalia.com
*
*   
* History:
*  Revision 1.0.0.0  
* 
* Tecnalia Research and Innovation
*/
package com.tecnalia.authz.log;

import java.io.ByteArrayOutputStream;

import org.jboss.security.xacml.interfaces.RequestContext;
import org.jboss.security.xacml.interfaces.ResponseContext;
import org.apache.log4j.Logger;

// TODO: Auto-generated Javadoc
/**
 * The Class PEPLog.
 */
public class PEPLog {
	
	/** The logger. */
	public static Logger logger; 


	/**
	 * Instantiates a new pEP log.
	 *
	 * @param obj the obj
	 */
	public PEPLog(Object obj) {
		super();
        PEPLog.logger = Logger.getLogger(obj.getClass());       
	}

	/**
	 * Log binary request.
	 *
	 * @param req the req
	 * @throws Exception the exception
	 */
	public void logBinaryRequest(RequestContext req) throws Exception  {
        ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
        req.marshall(tempOut);
        logger.debug("Dump request: " + tempOut.toString());
    }
	
	/**
	 * Log binary response.
	 *
	 * @param res the res
	 * @throws Exception the exception
	 */
	public void logBinaryResponse(ResponseContext res) throws Exception{
	    ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
	    res.marshall(tempOut);
	    logger.debug("Dump actual response: " + tempOut.toString());
	}

	/**
	 * Log message.
	 *
	 * @param msg the msg
	 */
	public void logMessage(String msg){
		logger.debug(msg);

	}

	/**
	 * Info.
	 *
	 * @param msg the msg
	 */
	public void info(Object msg){
		logger.info(msg);

	}
	
	/**
	 * Debug.
	 *
	 * @param msg the msg
	 */
	public void debug(Object msg){
		logger.debug(msg);

	}

}
